module.exports = {
  //抽离公共代码 缓存
  webpack: {
    configure(webpackConfig) {
      if (webpackConfig.mode === "production") {
        //抽离公共代码 只在生产环境
        if (webpackConfig.optimization == null) {
          webpackConfig.optimization = {};
        }
        webpackConfig.optimization.splitChunks = {
          chunks: "all",
          cacheGroups: {
            antd: {
              name: "antd-chunk",
              test: /antd/,
              priority: 100, //权限
            },
            reactDom: {
              name: "reactDom-chunk",
              test: /react-dom/, //匹配
              priority: 99, //权限
            },
            vendors: { //第三方
              name: "vendors-chunk",
              test: /node-modules/, //匹配
              priority: 98, //权限
            },
          },
        };
        return webpackConfig
      }
    },
  },

  //配置代理
  devServer: {
    port: 8000, //B 端 ：前端端口
    proxy: {
      "/api": "http://localhost:3005", //Mock
    },
  },
};
